//
//  HomeCollectionViewCell.m
//  Mahjong
//
//  Created by mc on 16/8/31.
//  Copyright © 2016年 Elliot. All rights reserved.
//

#import "HomeCollectionViewCell.h"

@implementation HomeCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.imgView = [[UIImageView alloc] init];
        _imgView.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:_imgView];
        self.imgView.image = [UIImage imageNamed:@"abc.jpg"];
        self.firstLabel = [[UILabel alloc] init];
        _firstLabel.backgroundColor = [UIColor whiteColor];
        _firstLabel.font = [UIFont systemFontOfSize:13];
        _firstLabel.numberOfLines = 0;
        [self.contentView addSubview:_firstLabel];
        
        self.priceLable = [[UILabel alloc] init];
        _priceLable.backgroundColor = [UIColor whiteColor];
        _priceLable.font = [UIFont systemFontOfSize:13];
        _priceLable.textColor = [UIColor redColor];
        [self.contentView addSubview:_priceLable];
        
        self.salesLable = [[UILabel alloc] init];
        _salesLable.backgroundColor = [UIColor whiteColor];
        _salesLable.font = [UIFont systemFontOfSize:13];
        [self.contentView addSubview:_salesLable];
        
    }
    return self;
}
-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    [super applyLayoutAttributes:layoutAttributes];
    
    self.imgView.frame = CGRectMake(0, 0, CGRectGetWidth(self.contentView.frame), CGRectGetHeight(self.contentView.frame)* 2 / 3);
    self.firstLabel.frame = CGRectMake(5, CGRectGetMaxY(self.imgView.frame), CGRectGetWidth(self.contentView.frame) - 10, CGRectGetHeight(self.contentView.frame)/6);
    self.priceLable.frame = CGRectMake(5, CGRectGetMaxY(self.firstLabel.frame), CGRectGetMaxX(self.contentView.frame)/2, CGRectGetHeight(self.contentView.frame)/6);
    self.salesLable.frame = CGRectMake(CGRectGetMaxX(self.contentView.frame)*2/3, CGRectGetMaxY(self.firstLabel.frame), CGRectGetMaxX(self.contentView.frame)/2, CGRectGetHeight(self.contentView.frame)/6);
}

- (void)awakeFromNib {
    // Initialization code
}

@end
